<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //将JSON对象转换为字符串  JSON.stringify（）
        var stu = {
            "name": '高伟杰',
            "age": 18,
        }
        var str = JSON.stringify(stu)

        console.log(typeof stu);
        console.log(str)
        console.log(typeof str);


        // 将字符串转换为JSON对象  JSON.parse()
        var string = '{"name":"高伟杰","age":18}'//语法不能有问题
        var obj = JSON.parse(string)
        console.log(obj);

        //内置函数eval（）方法也可以对字符串的内容进行解析计算------不推荐*  
        // var js= eval('('+string+')')
        // console.log(js);
        


        var arr = '[{"id": "d1","name": "高伟杰", "age": 21,  "phone": 1537733}, { "id":"d1","name": "高连友","age": 58,"phone": 1504297}]'
        var obj1 = JSON.parse(arr)
        console.log( obj1)
            

    </script>
</head>

<body>

</body>

</html>